import * as types from '../mutation-types'
const state = {
  myInfo: {
    name: 'guoguo'
  },
  sheInfo: {},
  love: [],
  say: ''
}
let getters = {
  myInfo: state => state.myInfo,
  sheInfo: state => state.sheInfo,
  love: state => state.love,
  say: state => state.say
}
const mutations = {
  [types.SET_MY_INFO] (state, data) {
    state.myInfo = data
  },
  [types.SET_SHE_INFO] (state, data) {
    state.sheInfo = data
  },
  [types.SET_LOVE] (state, data) {
    state.love = data
  },
  [types.SAY] (state, data) {
    state.say = data
  }
}
const actions = {
  putMyInfo ({commit}) {
    return new Promise((resolve, reject) => {
      setTimeout(function () {
        const data = {name: 'tnq', age: '20'}
        commit('SET_MY_INFO', data)
        resolve(data)
      }, 1000)
    })
  },
  putMyInfo2 ({commit}) {
    return new Promise((resolve, reject) => {
      setTimeout(function () {
        const data = {name: 'tnq', age: '20', say: '你好呀，很高心认识你'}
        commit('SET_SHE_INFO', data)
        resolve(data)
      }, 1000)
    })
  }
}
const user = {
  state,
  getters,
  mutations,
  actions
}
export default user
